/*
Copyright 2009 Johan Maasing, Mikael Forsberg

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
 */
package com.google.code.pj2r.resources.mocks;

import com.google.code.pj2r.DataAccessException;
import com.google.code.pj2r.MarshallingException;
import com.google.code.pj2r.Resource;
import com.google.code.pj2r.ResourceConflictException;

public class MockResource implements Resource {

	protected String testParam = null;
	protected String getId = null;
	protected String deleteId = null;
	protected String updateId = null;
	protected boolean get = false;
	protected boolean list = false;
	protected boolean create = false;
	protected boolean delete = false;
	protected boolean update = false;
	public static final String TEST_OBJECT = "{name: 'mock', id: '1'}";
	public static final String TEST_ARRAY = "[" + TEST_OBJECT + "]";

	public String getTestParam() {
		return testParam;
	}

	public void setTestParam(String testParam) {
		this.testParam = testParam;
	}

	public String get(String id) throws DataAccessException, MarshallingException {
		get = true;
		getId = id;
		return TEST_OBJECT;
	}

	public String list() throws DataAccessException, MarshallingException {
		list = true;
		return TEST_ARRAY;
	}

	public String create() throws DataAccessException {
		create = true;
		return "1";
	}

	public void delete(String id) {
		delete = true;
		deleteId = id;
	}

	public void update(String id) throws DataAccessException, ResourceConflictException {
		update = true;
		updateId = id;
	}

	public String getDeleteId() {
		return deleteId;
	}

	public String getGetId() {
		return getId;
	}

	public String getUpdateId() {
		return updateId;
	}

	public boolean isCreate() {
		return create;
	}

	public boolean isDelete() {
		return delete;
	}

	public boolean isList() {
		return list;
	}

	public boolean isUpdate() {
		return update;
	}

	public boolean isGet() {
		return get;
	}
}
